<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.3.6/axios.js"></script>
    <title>Document</title>
</head>
<body>
    <button id="ge">GET请求</button>
    <button id="pos">POST请求</button>
    <div class="container"></div>
    <!-- <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.3.6/esm/axios.min.js"></script> -->
    <script>
        let container = document.querySelector('.container')
    function getRequest(){
        axios({
        method:'get',
        url:"http://localhost:8066/api/home",
        headers:{
            
        }
        }).then(val => {
            console.log('val',val)
            let {data:res} = val
            container.innerHTML = JSON.stringify(res.data.colication)
        })
    }
    let ge = document.querySelector('#ge')
    ge.addEventListener('click',getRequest)
    let pos = document.querySelector('#pos')
    pos.addEventListener('click',()=>{
        axios({
            method:"POST",
            headers:{"Cache-Control":"max-age=5"},
            url:'http://localhost:8066/api/postcacheapi'
        })
    })
    </script>
</body>
</html>